﻿using System;
using System.Collections.Generic;
using System.Data.EntityClient;
using System.Data.Metadata.Edm;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Itfort.TestConsole
{
	class Program
	{
		public string x { get; set; }
		static void Main(string[] args)
		{
			MetadataWorkspace metadata = new MetadataWorkspace(
					new String[]{
						"res://*/"},
					new Assembly[] { Assembly.LoadFrom("Itfort.UserCenter.dll") }
				);

			var entityContainers = metadata.GetItems<EntityContainer>(DataSpace.CSpace);

			foreach (var entityContainer in entityContainers)
			{
				foreach (var entitySet in entityContainer.BaseEntitySets)
				{
					foreach (var member in entitySet.ElementType.Members)
					{
						EdmProperty edmProperty = member as EdmProperty;
						if (edmProperty != null)
						{
							Console.Write(edmProperty.TypeUsage.EdmType.Name);
							if (edmProperty.Nullable)
							{
								Console.Write("?");
							}

							Console.Write(" " + member.Name);
							Console.WriteLine(" { get; set; }");

						}
					}
				}
			}
		}
	}
}
